package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.entity.Document;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface DocumentMapper extends BaseMapper<Document> {

    /**
     * 统计总下载次数
     * @return 总下载次数
     */
    @Select("select sum(download_count) from documents")
    Integer sumDownloadCount();

    /**
     * 按是否公开统计文档数量
     * @param isPublic 是否公开 (private/pending_review/public)
     * @return 文档数量
     */
    @Select("select count(*) from documents where is_public = #{isPublic}")
    Integer countByIsPublic(String isPublic);

    /**
     * 按状态统计文档数量
     * @param status 文档状态
     * @return 文档数量
     */
    @Select("select count(*) from documents where status = #{status}")
    Integer countByStatus(String status);
}